mod macro_economics;
mod policy;
mod behavioral;

pub use macro_economics::MacroEconomicIndicators;
pub use policy::{PolicyTool, PolicyImpact};
pub use behavioral::BehavioralFactors;

/// 经济系统核心模型
pub struct EconomicSystem {
    pub indicators: MacroEconomicIndicators,
    pub policies: Vec<PolicyTool>,
    pub behavioral_factors: BehavioralFactors,
}

impl EconomicSystem {
    /// 创建新经济系统
    pub fn new() -> Self {
        EconomicSystem {
            indicators: MacroEconomicIndicators::default(),
            policies: Vec::new(),
            behavioral_factors: BehavioralFactors::default(),
        }
    }

    /// 执行经济周期模拟
    pub fn simulate_cycle(&mut self) {
        // 计算政策影响
        let policy_impact = self.calculate_policy_impact();
        
        // 更新宏观经济指标
        self.indicators.update(&policy_impact);
        
        // 应用行为因素
        self.apply_behavioral_effects();
    }

    fn calculate_policy_impact(&self) -> PolicyImpact {
        self.policies.iter()
            .fold(PolicyImpact::default(), |acc, policy| {
                acc.combine(&policy.estimate_impact(&self.indicators))
            })
    }

    fn apply_behavioral_effects(&mut self) {
        self.indicators.gdp *= self.behavioral_factors.productivity_bias;
        self.indicators.inflation += self.behavioral_factors.inflation_expectation;
    }
}